<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>unitTest file template</title>
    <link href="<%=staticRelativePath%>/normalize.css" rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
table{
    width: 100%;
}
table, th, td {
    border: 1px solid black;
    text-align: center;
}
.table-header{
    background-color: #88898B;
    color: white;
}
.testcase-tr{
    background-color: #C8C9CA;
}
.hide-td-border{
    border:none;
}
.colspan-text-align{
    text-align: start;
}
.function-count{
    text-align: end;
}
.function-test-count{
    text-align: end;
}
.test-result-succeed{
    background-color: #4DD5B3;
}
.test-result-nonStrictSucceed{
    background-color: #BF901D;

}
.test-result-failed{
    background-color: #CC3E35;
}
.test-result-exception{
    background-color: #FFBB36;
}
.test-result-codeDefect{
    background-color: #DE640F;
}
.test-result-noResult{
    background-color: #7B7B7B;
}
.test-result-unknown{
    background-color: #5188F4;
}
tr {
    page-break-inside: avoid;
    break-inside: avoid;
}
.back-to-top {
    margin: 20px;
    text-align: center;
}
a {
    text-decoration: none;
}
a:visited {
    color: #00e; 
    text-decoration: none; /* 去掉下划线等文本修饰 */
}
.coverage-blocks table{
    margin-top: 1em;
}
.coverage-blocks .content {
    text-align: left;
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
}
.coverage-blocks .line {
    width: 10%;
    font-weight: bold;
}
.coverage-blocks .sign {
    width: 5%;
    font-weight: bold;
}
.coverage-blocks .block {
    border-bottom: 3px solid;
}
.coverage-blocks .table-header th {
    text-align: left;
}
</style>
<body>
    <div>
        <div class="file-name" id = "top">
            <h1>
                【<%= fileName%>】
            </h1>
        </div>
        <div class="function-count">该文件共包含<%= summary.functionCount%>个函数</div>
        <!--file info-->
        <div>
            <table>
                <tbody>
                    <tr class="table-header">
                        <th>用例个数</th>
                        <th>通过</th>
                        <th>通过*</th>
                        <th>未通过</th>
                        <th>执行异常</th>
                        <th>运行时错误</th>
                        <th>无结果</th>
                        <th>未执行</th>
                    </tr>
                    <tr>
                        <td><%= summary.tests.total%></td>
                        <td><%= summary.tests.succeed%></td>
                        <td><%= summary.tests.nonStrictSucceed%></td>
                        <td><%= summary.tests.failed%></td>
                        <td><%= summary.tests.exception%></td>
                        <td><%= summary.tests.codeDefect%></td>
                        <td><%= summary.tests.noResult%></td>
                        <td><%= summary.tests.unknown%></td>
                    </tr>
                </tbody>
            </table>
        </div>
        <!--function list-->
        <div class="function-list">
            <% functions.forEach((func)=>{ %>
                <div>
                    <div class="function-name">
                        <h2 id="<%= func.functionName%>">
                            <%= func.functionName %>
                        </h2>
                    </div>
                     <!--function info-->
                    <div class="function-info">
                         <div>函数声明：<%= func.summary.declaration%></div>
                         <div>函数描述：<%= func.summary.description||'无'%></div>
                         <%func.udfs.forEach((udf)=>{%>
                            <div><%= udf.name%>：<%= udf.value||'无'%></div>
                         <%})%>
                          <!--integration function-->
                         <%if(isIntegrationTest){%>
                         <div>集成函数（共<%= func.integrationFunctionsCount%>个）:</div>
                           <%func.integrationFunctions.forEach((integrationFunction)=>{%>
                             <%= integrationFunction.name%>
                          <%})%>
                         <%}%>
                         <!--function coverages list-->
                         <div class="function-coverages">
                            <div class="function-test-count">该函数共包含<%= func.summary.testCount%>个用例</div>
                            <div class="function-coverage-list">
                                <table >
                                  <tbody>
                                    <tr class="table-header">
                                      <%func.summary.coverages.forEach((coverage)=>{%>
                                          <th><%= coverage.name%></th>
                                      <%})%>
                                    </tr>
                                    <tr>
                                        <%func.summary.coverages.forEach((coverage)=>{%>
                                            <td><%= coverage.value%></td>
                                         <%})%> 
                                    </tr>
                                </tbody>
                                </table>
                            </div>
                         </div>
                         <%if (func.summary.codeCoverageDetails) {%>
                         <div class="coverage-blocks">
                             <table>
                                 <colgroup>
                                     <col style="width:10%">
                                     <col>
                                     <col style="width:5%">
                                 </colgroup>
                                 <%func.summary.codeCoverageDetails.forEach((detail)=>{%>
                                     <tr class="table-header">
                                         <th colspan="3">&nbsp;&nbsp;<%= detail.title%>&nbsp;&nbsp;<%= detail.coverage%></th>
                                     </tr>
                                     <%detail.blocks.forEach(({ lines })=>{%>
                                         <tbody class="block">
                                         <%lines.forEach((line)=>{%>
                                             <tr>
                                                 <td class="line"><%= line.line%></td>
                                                 <td class="content"><%= line.content%></td>
                                                 <td class="sign"><% if (line.sign && line.sign[0]===true) {%>+<%} else if (line.sign && line.sign[0]===false) {%>-<%}%></td>
                                             </tr>
                                         <%})%>
                                         </tbody>
                                     <%})%>
                                 <%})%>
                             </table>
                         </div>
                         <%}%>
                         <!--function tests list-->
                         <div class="function-tests-list">
                            <%func.tests.forEach((testcase)=>{%>
                                <div class="function-testcase-info">
                                    <div class="function-testcase-name"><h3><%= testcase.group%>用例<%= testcase.index%></h3></div>
                                    <div class="function-testcase-info-table">
                                        <table>
                                         <tbody>
                                             <tr class="function-testcase-header table-header">
                                                 <%if(testcase.invokedFuncCoverage){%>
                                                     <th class="hide-td-border colspan-text-align">函数覆盖 <%= testcase.invokedFuncCoverage%></th>
                                                 <%}%>
                                                 <%if(testcase.invokeCoverage){%>
                                                     <th class="hide-td-border colspan-text-align">调用覆盖 <%= testcase.invokeCoverage%></th>
                                                 <%}%>
                                                 <%if(testcase.statementCoverage){%>
                                                     <th class="hide-td-border colspan-text-align">语句覆盖 <%= testcase.statementCoverage%></th>
                                                 <%}%>
                                                 <%if(testcase.branchCoverage){%>
                                                     <th class="hide-td-border colspan-text-align">分支覆盖 <%= testcase.branchCoverage%></th>
                                                 <%}%>
                                                 <%if(testcase.conditionCoverage){%>
                                                    <th class="hide-td-border colspan-text-align">条件覆盖 <%= testcase.conditionCoverage%></th>
                                                 <%}%>
                                                 <%if(testcase.decisionCoverage){%>
                                                     <th class="hide-td-border colspan-text-align">决策覆盖 <%= testcase.decisionCoverage%></th>
                                                 <%}%>
                                                 <%if(testcase.mcdcCoverage){%>
                                                     <th class="hide-td-border colspan-text-align">MC/DC <%= testcase.mcdcCoverage%></th>
                                                 <%}%>
                                                 <%if(func.summary.coverages.length === 1){%>
                                                     <th class="hide-td-border colspan-text-align"></th>
                                                     <th class="hide-td-border colspan-text-align"></th>
                                                 <%} else if(func.summary.coverages.length === 2){%>
                                                     <th class="hide-td-border colspan-text-align"></th>
                                                 <%}%>
                                                 <!--test result-->
                                                 <%if(testcase.resultKind==='succeed'){%>
                                                     <th class="test-result-succeed hide-td-border">通过</th>
                                                 <%}else if(testcase.resultKind==='nonStrictSucceed'){%>
                                                     <th class="test-result-nonStrictSucceed hide-td-border">通过*</th>
                                                 <%}else if(testcase.resultKind==='failed'){%>
                                                     <th class="test-result-failed hide-td-border">未通过</th>
                                                 <%}else if(testcase.resultKind==='exception'){%>
                                                     <th class="test-result-exception hide-td-border">执行异常</th>
                                                 <%}else if(testcase.resultKind==='codeDefect'){%>
                                                     <th class="test-result-codeDefect hide-td-border">运行时错误</th>
                                                 <%}else if(testcase.resultKind==='noResult'){%>
                                                     <th class="test-result-noResult hide-td-border">无结果</th>
                                                 <%}else if(testcase.resultKind==='unknown'){%>
                                                     <th class="test-result-unknown hide-td-border">未执行</th>
                                                 <%}%>
                                             </tr>
                                             <%if(!testcase.isIntegrationTest){%>
                                              <tr class="testcase-tr">
                                                <td class="colspan-text-align" colspan=<%= Math.max(4, func.summary.coverages.length+1)%>>
                                                  用例标识：<%= testcase.identifier||'无'%>
                                              </td>
                                             </tr>
                                             <%}%>
                                             <tr class="testcase-tr">
                                                <td class="colspan-text-align" colspan=<%= Math.max(4, func.summary.coverages.length+1)%>>
                                                  用例描述：<%= testcase.description || '无' %>
                                                </td>
                                            </tr>
                                            <tr class="testcase-tr">
                                                <td class="colspan-text-align" colspan=<%= Math.max(4, func.summary.coverages.length+1)%>>
                                                    需求关联信息：<%= testcase.requirementInfo || '无' %>
                                                </td>
                                            </tr>
                                            <tr class="testcase-tr">
                                                <td class="colspan-text-align" colspan=<%= Math.max(4, func.summary.coverages.length+1)%>>
                                                    用例分组及编号：<%= testcase.typeNumber || '无' %>
                                                </td>
                                            </tr>
                                             <% testcase.udfs.forEach((testudf)=>{ %>
                                                 <tr class="testcase-tr">
                                                    <td class="colspan-text-align" colspan=<%= Math.max(4, func.summary.coverages.length+1)%>>
                                                        <%= testudf.name%>:<%= testudf.value||'无'%>
                                                    </td>
                                                </tr>
                                             <% }) %>
                                             <tr><td class="colspan-text-align" colspan=<%= Math.max(4, func.summary.coverages.length+1)%>>初始化代码</td></tr>
                                             <% if(testcase.detail.prelude){%>
                                              <%testcase.detail.prelude.forEach((prelude)=>{%>
                                                <tr class="testcase-prelude">
                                                 <td class="colspan-text-align hide-td-border" colspan=<%= Math.max(4, func.summary.coverages.length+1)%>>
                                                        <%= prelude.line%>
                                                 </td>
                                              </tr>
                                              <%})%>
                                             <%}else{%>
                                             <tr><td class="colspan-text-align" colspan=<%= Math.max(4, func.summary.coverages.length+1)%>>
                                                无
                                             </td></tr>
                                             <%}%>
                                            </tbody>
                                        </table>
                                        <table>
                                            <tbody>

                                             <!--test input-->
                                             <tr class="testcase-input-head testcase-tr">
                                                <td>输入分类</td>
                                                <td width="60%">变量</td>
                                                <td colspan=<%= Math.max(2, func.summary.coverages.length-1)%>>赋值</td>
                                             </tr>
                                             <% if (testcase.detail && testcase.detail.input) {%>
                                             <%testcase.detail.input.forEach((input)=>{%>
                                              <tr class="testcase-input-value">
                                                <td><%= input.category%></td>
                                                <td width="60%">
                                                    <%= input.variable%><br/>
                                                    <%if(input.location){%>
                                                        起始:(<%= input.location.begin.line%>行,<%= input.location.begin.column%>列);结束:(<%= input.location.end.line%>行,<%= input.location.end.column%>列)
                                                    <%}%>
                                                </td>
                                                <td colspan=<%= Math.max(2, func.summary.coverages.length-1)%>><%= input.value%></td>
                                              </tr>
                                             <%})%>
                                            <%}%>
                                            <!--test output-->
                                            <tr class="testcase-output-head testcase-tr">
                                                <td>输出分类</td>
                                                <td width="60%">变量</td>
                                                <td>预期值</td>
                                                <td colspan=<%= Math.max(0, func.summary.coverages.length-2)%>>实际值</td>
                                            </tr>
                                            <% if (testcase.detail && testcase.detail.output) {%>
                                            <%testcase.detail.output.forEach((output)=>{%>
                                                <tr class="testcase-output-value">
                                                  <td><%= output.category%></td>
                                                  <td width="60%">
                                                      <%= output.variable%><br/>
                                                      <%if(output.location){%>
                                                       起始:(<%= output.location.begin.line%>行,<%= output.location.begin.column%>列);结束:(<%= output.location.end.line%>行,<%= output.location.end.column%>列)
                                                      <%}%>
                                                  </td>
                                                  <td><%= output.value%></td>
                                                  <td colspan=<%= Math.max(0, func.summary.coverages.length-2)%>><%= output.result%></td>
                                                </tr>
                                               <%})%>
                                            <%}%>
                                            <% if (testcase.error) { %>
                                                <tr class="testcase-output-head testcase-tr">
                                                    <td colspan=<%= Math.max(4, func.summary.coverages.length + 1)%>>
                                                        <% if (testcase.rKind === 101) {%>执行时发生运行时错误，请检查代码是否存在除零、数组越界等错误；或者检查用例或代码里是否存在非法指针访问。
                                                        <% } else if (testcase.rKind === 102) {%>运行超时，请检查代码中是否存在无限循环代码等。
                                                        <% } else if (testcase.rKind === 111) {%>发生系统错误。
                                                        <% } else if (testcase.rKind === 112) {%>发生插桩错误。
                                                        <% } else if (testcase.rKind === 113) {%>发生编译错误，请结合具体的错误内容检查用例数据。
                                                        <% } else if (testcase.rKind === 0) {%>用例数据发生变化，与导出的测试脚本不一致。
                                                        <% } %>
                                                    </td>
                                                </tr>
                                            <%}%>
                                        </tbody>
                                        </table>
                                    </div>
                                </div>
                            <%})%>
                         </div>
                         <!--code defects -->
                         <%if(func.codeDefects&&func.codeDefects.length > 0){%>
                         <div class="function-code-defects-list">
                           <div><h3>代码缺陷管理</h3></div>
                           <div class="function-code-defect-info">
                                <table >
                                    <tbody>
                                        <tr class="table-header">
                                            <th>编号</th>
                                            <th>缺陷描述</th>
                                            <th>位置(行;列)</th>
                                            <th>关联用例</th>
                                            <th>缺陷类型</th>
                                        </tr>
                                        <%func.codeDefects.forEach((codeDefect)=>{%>
                                            <tr>
                                                <td><%= codeDefect.index%></td>
                                                <td><%= codeDefect.desc%></td>
                                                <td><%= codeDefect.locationStr%></td>
                                                <td><%= codeDefect.testCases%></td>
                                                <td><%= codeDefect.typeStr%></td>
                                            </tr>
                                        <%})%>
                                    </tbody>
                                </table>
                           </div>
                         </div>
                         <%}%>
                    </div>
                    <%if(jumpable){%>
                     <div class="back-to-top">[ <a href="#top">返回开始</a> ｜ <a href="#<%= func.functionName%>">返回本节</a> ]</div>
                    <%}%>
                </div>
            <% })%>
        </div>
    </div>
</body>

</html>
